package com.atguigu.daijia.driver.controller;

import com.atguigu.daijia.common.login.JiYunLogin;
import com.atguigu.daijia.common.result.Result;
import com.atguigu.daijia.common.util.AuthContextHolder;
import com.atguigu.daijia.driver.service.OrderService;
import com.atguigu.daijia.model.vo.order.CurrentOrderInfoVo;
import com.atguigu.daijia.model.vo.order.NewOrderDataVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@Tag(name = "订单API接口管理")
@RestController
@RequestMapping("/order")
@SuppressWarnings({"unchecked", "rawtypes"})
public class OrderController {
    @Autowired
    OrderService orderService;
@Operation(summary = "查询订单状态")
    @JiYunLogin
    @GetMapping("/getOrderStatus/{orderId}")
    public Result<Integer> getOrderStatus(@PathVariable Long orderId){
    return Result.ok(orderService.getOrderStatus(orderId));
    }
@Operation(summary = "查询司机新订单数据")
    @JiYunLogin
    @GetMapping("/findNewOrderQueueData")
    public Result<List<NewOrderDataVo>>findNewOrederQueueData(){
    Long driverId= AuthContextHolder.getUserId();
    return Result.ok(orderService.findNewOrederQueueData(driverId));
}
@Operation(summary = "查询司机当前订单")
    @JiYunLogin
    @GetMapping("/searchDriverCurrentOrder")
public Result<CurrentOrderInfoVo>searchDriverCurrentOrder(){
    CurrentOrderInfoVo currentOrderInfoVo = new CurrentOrderInfoVo();
    currentOrderInfoVo.setIsHasCurrentOrder(false);
    return Result.ok(currentOrderInfoVo);
}
@Operation(summary = "司机抢单")
    @JiYunLogin
    @GetMapping("/robNewOrder/{orderId}")
    public Result<Boolean>robNewOrder(@PathVariable Long orderId){
    Long driverId= AuthContextHolder.getUserId();
    return Result.ok(orderService.robNewOrder(driverId,orderId));
}

}

